<?php
require_once 'application/library/controller/gcLBasicAction.php';
require_once 'application/modules/site/services/site_services_newsEditService.php';
require_once 'application/constant/templatName.php';

/**
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 */
class site_newsEditController extends gcLBasicAction{
    
    private $objService;
    /**
     * indexAction
     * @return 
     */
    public function indexAction(){
        $this->initMenu("4");
        $this->boolUserTypeCheck("4");
        $strEditType = $this->getParam("EditType");
        $this->gcView->EditType = $strEditType;
        if ($strEditType=="2") {
            $this->gcView->divTitle = "发布新闻";
        } else if ($strEditType=="1") {
            $this->gcView->divTitle = "新闻编辑";
            $strInfoNo  = $this->getParam("InfoNo");

            $this->gcView->InfoNo = $strInfoNo;
            $this->objService = new site_services_newsEditService();
            $arrResult = $this->objService->pbGetNewsContent($strInfoNo);
            $this->gcView->arrResult = $arrResult;
        }
        $this->gcView->render("newsEdit.tpl");
    }
    
    public function saveAction() {
        $strTitle   = $this->getParam("Title");
        $strContent = $this->getParam("Content");
        $strInfoNo = $this->getParam("InfoNo");
        
        $this->objService = new site_services_newsEditService();
        $this->objService->pbSaveNews($strInfoNo, $strTitle, $strContent);
        //var_dump($strTitle);
        jsonHelper::outPutJson(null);
    }
    
    public function addnewsAction() {
        $strTitle   = $this->getParam("Title");
        $strContent = $this->getParam("Content");
        $strInfoNo = $this->getParam("InfoNo");
        
        $this->objService = new site_services_newsEditService();
        $this->objService->pbAddNews($strTitle, $strContent);
        jsonHelper::outPutJson(null);
    }
    
    function deletenewsAction() {
        $strInfoNo = $this->getParam("infoNo");

        $this->objService = new site_services_newsEditService();
        $this->objService->pbDeleteNews($strInfoNo);
        $this->forward("site/newsList/index");
    }
}
